﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace Factur_IT.WorkingHour
{
    public partial class addWorkingHour : System.Web.UI.Page
    {
        public int projectid;
        public int companyid;
        protected void Page_Load(object sender, EventArgs e)
        {
            bool loggedIn = FacturIT.Service.FacturITManager.Instance.IsLoggedID();

            if (loggedIn != true)
                Response.Redirect("~/Account/login.aspx");
            
            projectid = Convert.ToInt32(Request.Params["ProjectID"]);
            companyid = Convert.ToInt32(Request.Params["CompanyID"]);
            string projectnaam = FacturIT.Service.FacturITManager.Instance.ReadProject(projectid).ProjectName;
            lblProjectName.Text = projectnaam;
        }

        protected void btnAddHours_Click(object sender, EventArgs e)
        {
            int companyprojectid = FacturIT.Service.FacturITManager.Instance.ReadCompanyProjectByProjectAndCompany(projectid, companyid).CompanyProjectID;

            DateTime van = calVan.SelectedDate;
            DateTime tot = calTot.SelectedDate;
            FacturIT.Service.FacturITManager.Instance.AddWorkingHour(companyprojectid, van, tot, false);
            Response.Redirect("~/Project/projectDetails.aspx?ProjectID=" +projectid);
        }
    }
}